﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Media;
using VNet.VisiSuite.Common.Helpers;
using VNet.VisiSuite.Service.Contact.Message.ProductionData;
using VNet.VisiSuite.VisiBoard.Common.Helpers;

namespace VNet.VisiSuite.VisiBoard.Models
{
    public class DowntimeModel : BaseModel
    {
        private static BusinessLogic.VisiBoard _visi_board = null;

        private List<DowntimeGraphDataItem> _downtime_chart_data = new List<DowntimeGraphDataItem>();

        public DowntimeModel()
        {
            _visi_board = BusinessLogic.VisiBoard.instance();
            _downtime_chart_data = _visi_board.GetDowntimeChartData();
        }

        public Brush HeaderBackground
        {
            get
            {
                Brush brush;
                string fg, bg;
                if (_visi_board.alarmColors(100, _visi_board.IsMachineRunning, out fg, out bg))
                    brush = new SolidColorBrush(ColorHelper.StringToColor(bg, Colors.Red));
                else
                    brush = new SolidColorBrush(Colors.Red);
                return brush;
            }
        }

        public DateTime ShiftStart
        {
            get { return _visi_board.ShiftStart; }
        }

        public DateTime ShiftEnd
        {
            get
            {
                return _visi_board.ShiftEnd;
            }
        }

        public List<DowntimeGraphDataItem> DowntimeChartData
        {
            get
            {
                return _downtime_chart_data;
            }
        }
    }


    public class DowntimeLineChartModel:BaseModel
    {
        private string _time;
        private double _duration;

        public string Time
        {
            get { return _time; }
            set
            {
                _time = value;
                OnPropertyChanged("Time");
            }
        }

        public double Duration
        {
            get { return _duration; }
            set
            {
                _duration = value;
                OnPropertyChanged("Duration");
            }
        }
    }

}
